package com.hs.sfzy.controller;

import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.PsychReply;
import com.hs.sfzy.service.PsychReplyService;
import com.hs.sfzy.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import java.util.List;

@RestController
@RequestMapping("psychReply")
public class PsychReplyController {
    @Autowired
    PsychReplyService psychReplyService;
@GetMapping("page")
    public R getAll(@RequestParam(required = false,defaultValue = "1") int pageNum,
                    @RequestParam(required = false,defaultValue = "3")  int pageSize){
        PageInfo<PsychReply> page = psychReplyService.getAll(pageNum, pageSize);
        return R.ok(page);
    }
    @GetMapping("all")
    public R getTow(@RequestParam(required = false,defaultValue = "1") int pageNum,
                    @RequestParam(required = false,defaultValue = "3")  int pageSize){
        PageInfo<PsychReply> all = psychReplyService.getTow(pageNum, pageSize);
        return R.ok(all);
    }
    @GetMapping("getReplyByPsychId")
    public R getReplyByPsychId(Integer id){
        List<PsychReply> replyByPsychId = psychReplyService.getReplyByPsychId(id);
        return R.ok(replyByPsychId);
    }
    @PostMapping("add")
    public R addReply(@RequestBody PsychReply psychReply){
        int i = psychReplyService.addReply(psychReply);
        return i > 0 ? R.ok() : R.fail();
    }

}
